SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
1.5 KB · 25 lines tsx
Raw Blame History
1import { ImageResponse } from 'next/og';2import { Fallback, Wallpaper } from '@/components/brand/og';3import { apiD1, safe } from '@/lib/api';4import { fmtGb, fmtInt, num } from '@/lib/format';5import { routes, SITE_NAME } from '@/lib/site';67export const runtime = 'nodejs';8export const alt = `Artifact on ${SITE_NAME}`;9export const size = { width: 1200, height: 630 };10export const contentType = 'image/png';1112export default async function ArtifactOgImage({ params }: { params: Promise<{ slug: string }> }) {13  const { slug } = await params;14  const d = await safe(apiD1.model(slug));15  if (!d || d.entity_type !== 'artifact') return new ImageResponse(<Fallback label="Artifact" />, { ...size });16  const a = d.attributes ?? {};17  const counters: [string, string][] = [];18  if (typeof a.quant_format === 'string') counters.push(['Format', String(a.quant_format).toUpperCase()]);19  if (num(a.file_size_gb) !== null) counters.push(['File size', fmtGb(a.file_size_gb, 1)]);20  if (num(a['metric.downloads']) !== null) counters.push(['Downloads', fmtInt(a['metric.downloads'])]);21  if (d.organization) counters.push(['Publisher', d.organization.name.slice(0, 18)]);22  const kind = d.artifact_kind ?? 'artifact';23  return new ImageResponse(<Wallpaper eyebrow={`Artifact · ${kind}`} title={d.name} subtitle={d.canonical ? `${kind.charAt(0).toUpperCase()}${kind.slice(1)} of ${d.canonical.name} — not an independent model` : 'Packaging of a canonical model'} counters={counters.slice(0, 4)} footer={`www.ai-atlas.co${routes.artifact(d.slug)}`} markPx={220} />, { ...size });24}25